from django.db import models

# Create your models here.


from django.db import models
from department.models import Department   # 系部
from clazz.models import Clazz             # 班级

class Student(models.Model):
    """学生"""
    student_num = models.CharField(max_length=20, unique=True, null=True, blank=True, verbose_name='学号')
    name = models.CharField(max_length=100, verbose_name='姓名')
    sex = models.BooleanField(default=1, verbose_name='性别')          # 1 男 0 女
    age = models.IntegerField(verbose_name='年龄')
    clazz = models.ForeignKey(Clazz, on_delete=models.SET_NULL,
                              null=True, blank=True,
                              related_name='students',
                              verbose_name='所属班级')
    department = models.ForeignKey(Department, on_delete=models.SET_NULL,
                                   null=True, blank=True,
                                   related_name='stu_dept',
                                   verbose_name='所属系部')
    description = models.TextField(blank=True, verbose_name='个性签名')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')

    class Meta:
        db_table = 'tb_student'
        verbose_name = '学生'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


